use std::collections::HashSet;

struct Solution {}

fn main() {}

impl Solution {
    pub fn add_spaces(s: String, spaces: Vec<i32>) -> String {
        let mut res = String::from("");
        let spaces_set: HashSet<i32, S> = HashSet::from_iter(spaces.iter().cloned());
        if spaces_set.contains(&0) {
            res.push_str(" ");
        }

        let mut idx = 0;
        for c in s.chars() {
            res.push(c);
            idx += 1;
            if spaces_set.contains(&idx) {
                res.push(' ');
            }
        }
        res
    }
}